package leaf.cloud.test.controller;

import leaf.cloud.common.core.web.controller.BaseController;
import leaf.cloud.common.redis.service.RedisServiceOne;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RefreshScope
@RestController
@RequestMapping("provider")
public class ProviderController extends BaseController {
    @Value("${spring.redis.database}")
    private String id;
    @Value("${user.name}")
    private String name;
    @Value("${user.age}")
    private String age;
    @Resource
    RedisServiceOne redisServiceOne;

    @GetMapping("getNacosConfig")
    public String providerTest() {
        String conf = "我是provider，已成功获取nacos配置中心的数据：(id:" + id + ",name:" + name + ",age:" + age + ")";
        redisServiceOne.setCacheObject("conf", conf);
        return conf;
    }
}